<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<head>
<title>登录</title>
<meta charset="utf-8">
<meta name="renderer" content="webkit|ie-comp|ie-stand">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta name="viewport"
	content="width=device-width,initial-scale=1,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no" />
<meta http-equiv="Cache-Control" content="no-siteapp" />
<link rel="shortcut icon" href="../../img/login.ico" />
<link rel="stylesheet" type="text/css" href="../../css/login.css">
<script type="text/javascript" src="../../js/jquery.min.js"></script>
<script>
	$(function() {
		//登录
		$("#submitBtn").click(function() {
			//点击提交之后serialize()方法将表单值序列化一下，就是将表单名和值处理成json的格式，并将值赋给data
			var data = $("#form").serialize();
			//以下是一个提交登录信息的ajax方法
			$.ajax({//就是用jQuery的方式向后台发一个异步的请求
				type : "post",//是请求的方法
				url : "http://localhost:8000/login",//url是请求的链接地址,会去转到post的login方法做判断
				data : data, //data是请求的参数，以json格式传递，例如{username: 'name', password: '123456'}
				dataType : "json", //预期服务器返回的数据类型
				success : function(data) {
					if ("success" == data.type) {
						window.parent.location.href = "html/list.html";
					} else {
						window.alert( data.msg);
					}
				}
			});
		});
	})
	//将回车键绑定提交按钮的两种方法
	$(window).keydown(function() {
		if (event.keyCode == "13") {
			$('#submitBtn').click();
		}
	});
	// document.onkeydown = function() {
	// 		var e = window.event
	// 	if ((e.keyCode || e.which) == 13) {
	// 		document.getElementById("submitBtn").click();
	// 	}
	// }
</script>
</head>
<body>
<div class="login">
	<h2>计算资源管理系统</h2><br>
	<div class="login-top">
		<h1>登&emsp;&emsp;录</h1>
		<form id="form" method="post">
			<input id="username" name="username" type="text" placeholder="账户">
			<input id="password" name="password" type="password" placeholder="密码">
		</form>
		<div class="forgot">
			<input id="submitBtn" type="submit" value="Login">
		</div>
	</div>
	<div class="login-bottom"></div>
</div>
<div class="copyright">
	<p>Copyright &nbsp; author © Jac</p>
</div>
</body>
</html>